﻿using PetaPoco;

namespace PushTask
{
    public class ConnectionBLL
    {
        /// <summary>
        /// 只要他不是一個的話,我這個就會去使用刪除數據庫中數據然後重新建立連接
        /// 是否console 已連接
        /// </summary>
        /// <returns></returns>
        public static bool AdminExist()
        {
            Database db = new Database();
            var count = db.FirstOrDefault<int>("select count(connectionId) from connect where isadmin=1");
            if (count == 1) return true;

            //刪除所有的isadmin的設備,然後重新連接
            db.Execute("delete from connect where isadmin=1");
            return false;
        }
    }
}
